#!/usr/bin/python
# -*- coding: utf-8 -*-

from sphinxapi import *
import sys, time

# library for sphinx full text search

class full_text_search:

    def __init__(self, host="localhost", port=9312):
        
        self.engine = SphinxClient()
        slef.engine.SetServer( host, port )
        self.engine.SetWeights( [100, 1] )
    

    def query(self, queryword, index='*', mode=SPH_MATCH_ALL):
        
        res = self.engine.Query ( query, index )
 
        if not res:
            print 'query failed: %s' % self.engine.GetLastError()
            sys.exit(1)
 
        if self.engine.GetLastWarning():
            print 'WARNING: %s\n' % self.engine.GetLastWarning()
        return res
        
        
